package com.chinacache.pqbs.entity.user;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Table(name = "RESOURCES")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Resource {

	private Integer id;

	private String name;

	private String resType;

	private String resString;

	private String descn;

	private Set<Role> roles = new HashSet<Role>(0);

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY) 
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	
	@Column(name = "NAME", unique = true, nullable = false, insertable = true, updatable = true, length = 20)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "TYPE", unique = true, nullable = false, insertable = true, updatable = true, length = 20)
	public String getResType() {
		return resType;
	}

	public void setResType(String resType) {
		this.resType = resType;
	}

	@Column(name = "RESSTRING", unique = true, nullable = false, insertable = true, updatable = true)
	public String getResString() {
		return resString;
	}

	public void setResString(String resString) {
		this.resString = resString;
	}

	@Column(name = "DESCN", unique = true, nullable = false, insertable = true, updatable = true)
	public String getDescn() {
		return descn;
	}

	public void setDescn(String descn) {
		this.descn = descn;
	}
 
	@ManyToMany(mappedBy = "resources")
	public Set<Role> getRoles() {
		return roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}
}
